{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from gs_quant.common import OptionType, OptionStyle\n",
    "from gs_quant.instrument import EqOption\n",
    "from gs_quant.session import Environment, GsSession\n",
    "from gs_quant.risk import MarketDataShockBasedScenario, MarketDataPattern, MarketDataShock, MarketDataShockType"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# external users should substitute their client id and secret; please skip this step if using internal jupyterhub\n",
    "GsSession.use(Environment.PROD, client_id=None, client_secret=None, scopes=('run_analytics',))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "eq_future_scenario = MarketDataShockBasedScenario(\n",
    "    shocks={\n",
    "        MarketDataPattern(\n",
    "            'Eq Future', '.STOXX50E', 'Reference Spot', ['2021-12-17'], mkt_quoting_style='Price'\n",
    "        ): MarketDataShock(MarketDataShockType.Override, 3800)\n",
    "    }\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "option = EqOption(\n",
    "    '.STOXX50E', expirationDate='3m', strikePrice='ATM', optionType=OptionType.Call, optionStyle=OptionStyle.European\n",
    ")\n",
    "\n",
    "with eq_future_scenario:\n",
    "    option_future_scenario_price = option.price()\n",
    "\n",
    "# Look at the difference between scenario and base prices\n",
    "print('Base price:     {:,.2f}'.format(option.price()))\n",
    "print('Future scenario price: {:,.2f}'.format(option_future_scenario_price))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "metadata": {
     "collapsed": false
    },
    "source": []
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
